@extends('layouts.back_stage')
@section('content')

    <div class="container">
        <div style="padding:20px 0;">
            <h3>黑名单列表</h3>
        </div>
        <table class="table">
            <thead>
            <tr>
                <th>用户姓名</th>
                <th>手机号</th>
                <th>区域</th>
                <th>区域编号</th>
                <th>&nbsp;&nbsp;&nbsp;&nbsp;操作</th>
            </tr>
            </thead>
            <tbody>
            @foreach($data as $whiteUser)
                <tr>
                    <td> {{ $whiteUser->username }}</td>
                    <td> {{ $whiteUser->user_tel }}</td>
                    <td> {{ $whiteUser->user_area }}</td>
                    <td> {{ $whiteUser->area_code }}</td>
                    <td>
                        <a onclick="moveToWhite({{ $whiteUser->id }},'recover')" id="delete">恢复至白名单</a>
                        <a onclick="moveToWhite({{ $whiteUser->id }},'delete')" id="delete">从黑名单移除</a>
                    </td>
                    <td></td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
    <script>
        function moveToWhite(id,flag) {
            $(".oText").text("确定要此操作吗？");
            $(".oMask").show();
            $(".oAnim").show();
            $(".oBtn0").attr("abc",id);
            $(".oBtn0").attr("def",flag);
        }
        /*点确定*/
        $(document).on('click','.oBtn0',function(){
            $(".oMask").hide();
            $(".oAnim").hide();
            var id=$(this).attr("abc");
            var flag=$(this).attr("def");
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                type:'post',
                url:'/backstage/toWhite',
                data:{
                    'id':id,
                    'flag':flag
                },
                success:function (data) {
                    $(".faceImg").attr("src","/img/laugh.png");
                    $(".oHandle").text("操作成功");
                    $(".oSuccess").show(0).delay(1000).hide(0);
                    window.location.reload();
                }
            });
        });
    </script>
@endsection